package com.uvnos4j.matilda.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.uvnos4j.matilda.commons.domain.AbstractTreeDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * 系统权限
 * <p>
 * Description:系统权限
 * </p>
 *
 * @author Guo.wl
 * @version v1.0.0
 * @see com.uvnos4j.matilda.system.domain
 * @since 2020-08-31 23:10:19
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_acl")
public class SysAcl extends AbstractTreeDomain<SysAcl> implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 父权限
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField(value = "parent_id")
    private Long parentId;
    /**
     * 权限名称
     */
    @TableField(value = "name")
    private String name;
    /**
     * 权限英文名称
     */
    @TableField(value = "enname")
    private String enname;
    /**
     * 权限值
     */
    @TableField(value = "value")
    private String value;
    /**
     * 权限类型：0->目录；1->菜单；2->按钮；3->其他（接口绑定权限）
     */
    @TableField(value = "type")
    private Integer type;
    /**
     * 图标
     */
    @TableField(value = "icon")
    private String icon;
    /**
     * 排序
     */
    @TableField(value = "seq")
    private Integer seq;
    /**
     * 资源路径
     */
    @TableField(value = "url")
    private String url;
    /**
     * 备注
     */
    @TableField(value = "note")
    private String note;
    /**
     * 角色是否有权限
     */
    @TableField(exist = false)
    private boolean checked = false;

    /**
     * 用户是否有操作权限
     */
    @TableField(exist = false)
    private boolean hasAcl = false;

    @Override
    public boolean isRoot() {
        return parentId == null || parentId == 0;
    }
}